package com.bookmanager.www.controller.rabbitmq;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: 风离
 * @Date: 2021/10/14/15:18
 * @Description:
 */
@Component
public class FanOutConsumer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "fanout-test",type = "fanout") //绑定交换机的名称和类型
            )
    })
    public void fanout1(String message)
    {
        System.out.println("第一个消费者："+message);
    }


    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "fanout-test",type = "fanout") //绑定交换机的名称和类型
            )
    })
    public void fanout2(String message)
    {
        System.out.println("第二个消费者："+message);
    }
}
